﻿#include "EntryLabel.h"
#include <QPainter>

EntryLabel::EntryLabel(QWidget *parent) : QLabel {parent} { }

void EntryLabel::paintEvent(QPaintEvent *event) {
    QFontMetrics fm(font());
    const auto &txt = fm.elidedText(text(), Qt::ElideRight, width(), Qt::TextWrapAnywhere);
    QPainter painter(this);
    painter.setRenderHints(QPainter::TextAntialiasing);
    painter.drawText(rect(), Qt::AlignVCenter | Qt::AlignLeft, txt);
    setToolTip(txt == text() ? "" : text());
}
